import struct
class structWrapper():
    def __init__(self,s=b''):
        self.data = s
        self.pos = 0
        
    def writeArr(self,a):
        self.data += a
        self.pos += len(a)
        
    def readArr(self,l):       
        self.pos += l   
        return self.data[self.pos-l:self.pos]
    
    def writeByte(self,b):
        self.data += struct.pack('B',b)
        self.pos += 1
        
    def writeWord(self,b):
        self.data += struct.pack('H',b)
        self.pos += 2    
    def writeDWord(self,b):
        self.data += struct.pack('I',b)
        self.pos += 4       
    def writeDouble(self,b):
        self.data += struct.pack('d',b)
        self.pos += 8
        
    def writeQ(self,b):
        self.data += struct.pack('Q',b)
        self.pos += 8   
    def writeFloat(self,b):
        self.data += struct.pack('f',b)
        self.pos += 4
        
    def readFloat(self):
        r = struct.unpack('f',self.data[self.pos:self.pos+4])[0]
        self.pos += 4
        return r
            
    def readByte(self):
        r = struct.unpack('B',self.data[self.pos:self.pos+1])[0]
        self.pos += 1
        return r
    
    def readWord(self):
        r = struct.unpack('H',self.data[self.pos:self.pos+2])[0]
        self.pos += 2
        return r
    def readDWord(self):
        r = struct.unpack('I',self.data[self.pos:self.pos+4])[0]
        self.pos += 4
        return r    
    def readDouble(self):
        r = struct.unpack('d',self.data[self.pos:self.pos+8])[0]
        self.pos += 8
        return r    
    
    def readQ(self):
        r = struct.unpack('Q',self.data[self.pos:self.pos+8])[0]
        self.pos += 8
        return r        
    
    def getLeftData(self):
        return self.data[self.pos:]
    
    def leftLen(self):
        return len(self.data)-self.pos
